/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "posDiscount")
@XmlRootElement
public class POSDiscount implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "posDiscountID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "description")
    private String discountDescription;
    @Basic(optional = false)
    @NotNull
    @Column(name = "flatRate")
    private float flat;
    @Basic(optional = false)
    @NotNull
    @Column(name = "pctRate")
    private float pct;
    @OneToMany(mappedBy = "discount")
    private Collection<POSLineItems> lineItemCollection;
    @OneToOne(mappedBy="growlerDiscount")
    private POSSetup posSetup;

    public POSDiscount() {
    }

    public POSDiscount(Integer id) {
        this.id = id;
    }

    public POSDiscount(Integer id, String discountDescription, float flat, float pct) {
        this.id = id;
        this.discountDescription = discountDescription;
        this.flat = flat;
        this.pct = pct;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDiscountDescription() {
        return discountDescription;
    }

    public void setDiscountDescription(String discountDescription) {
        this.discountDescription = discountDescription;
    }

    public float getFlat() {
        return flat;
    }

    public void setFlat(float flat) {
        this.flat = flat;
    }

    public float getPct() {
        return pct;
    }

    public void setPct(float pct) {
        this.pct = pct;
    }

    @XmlTransient
    public POSSetup getPOSSetup() {
        return posSetup;
    }

    public void setPOSSetup(POSSetup posSetup) {
        this.posSetup = posSetup;
    }

    @XmlTransient
    public Collection<POSLineItems> getLineItemCollection() {
        return lineItemCollection;
    }

    public void setLineItemCollection(Collection<POSLineItems> lineItemCollection) {
        this.lineItemCollection = lineItemCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof POSDiscount)) {
            return false;
        }
        POSDiscount other = (POSDiscount) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.posdiscount[ id=" + id + " ]";
    }
}
